package com.storage.mongo;

import java.text.ParseException;

import org.bson.types.ObjectId;

import com.google.code.morphia.annotations.Embedded;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.wink.charity.Charity;

@Entity
public class MongoCharity {	

	@Id
	private ObjectId Id;
	
	private String name;	
	private String description;
	private String charityCommunityID;
	@Embedded
	private MongoIdentity identity;
	private String amount;		

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getCharityCommunityID() {
		return charityCommunityID;
	}

	public void setCharityCommunityID(String charityCommunityID) {
		this.charityCommunityID = charityCommunityID;
	}

	public MongoIdentity getIdentity() {
		return identity;
	}

	public void setIdentity(MongoIdentity identity) {
		this.identity = identity;
	}
	
	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}
	
	public Charity toCharity() throws ParseException {
		Charity charity= new Charity();
		charity.setAmount(amount);
		charity.setCharityCommunityID(charityCommunityID);
		charity.setDescription(description);
		charity.setName(name);
		if(identity != null)
			charity.setIdentity(identity.toIdentity());
		else
			charity.setIdentity(null);
		
		return charity;
	}
}